package com.zprmb.udzt.view;

import android.app.Activity;
import android.app.Dialog;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

import com.zprmb.udzt.R;

public class LoadingDialog2 extends Dialog {

    private Activity mActivity;
    //private TextView loadingText;

    public LoadingDialog2(Activity context) {
        super(context, R.style.dialog_normal);
        mActivity = context;
        setContentView(R.layout.loading2);//loading
        setProperty();
        setCancelable(true);
//		getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);  
        //loadingText = (TextView) findViewById(R.id.loading_text);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
        return false;
    }

	/*public void setLoadingMessage(String message){
		if(!TextUtils.isEmpty(message)){
			loadingText.setText(message);
		}
	}*/

    /*public void show(String message) {
        if(!TextUtils.isEmpty(message)){
            loadingText.setText(message);
        }
        super.show();
    }
*/
    @Override
    public void show() {
        // TODO Auto-generated method stub
        super.show();

    }

    public void close() {
        if (!mActivity.isFinishing()) {
            mActivity.runOnUiThread(new Runnable() {
                public void run() {
                    if (isShowing()) {
                        dismiss();
                    }
                }
            });
        }
    }

    private void setProperty() {
        Window window = getWindow();
        WindowManager.LayoutParams p = window.getAttributes();
        Display d = getWindow().getWindowManager().getDefaultDisplay();
        p.height = (int) (d.getHeight() * 1);
        p.width = (int) (d.getWidth() * 1);
        window.setAttributes(p);
    }
}
